package p270jp.pxv.android.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import androidx.databinding.DataBindingUtil;
import com.bumptech.glide.Glide;
import java.util.Objects;
import p090d0.C2518n;
import p134ei.AnalyticsScreenName;
import p144f1.C3017s;
import p184gi.AnalyticsParameter;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.model.PixivIllust;
import p270jp.pxv.android.legacy.model.PixivImageUrls;
import p314lg.ViewHomeMangaItemBinding;
import p325m0.MutabilityOwnership;
import p330m5.GlideUrl;
import p374nm.BaseMuteLayout;
import p460r5.DrawableTransitionOptions;
import p470ri.HashtagService;
import p474rm.CropTransformation;
import p638y5.RequestOptions;
import p677zi.PixivImageLoader;

/* renamed from: jp.pxv.android.view.MangaListItemView */
/* loaded from: classes2.dex */
public class MangaListItemView extends BaseMuteLayout {

    /* renamed from: b */
    public final HashtagService f19557b = (HashtagService) C2518n.m7641d(HashtagService.class);

    /* renamed from: c */
    public ViewHomeMangaItemBinding f19558c;

    /* renamed from: d */
    public boolean f19559d;

    /* renamed from: e */
    public String f19560e;

    /* renamed from: f */
    public int f19561f;

    public MangaListItemView(Context context) {
        super(context);
    }

    @Override // p374nm.BaseMuteLayout
    /* renamed from: a */
    public View mo3337a() {
        ViewHomeMangaItemBinding g9Var = (ViewHomeMangaItemBinding) DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.view_home_manga_item, this, false);
        this.f19558c = g9Var;
        return g9Var.f2666e;
    }

    /* renamed from: c */
    public String m4488c(PixivIllust pixivIllust) {
        float f = ((float) pixivIllust.width) / ((float) pixivIllust.height);
        if (f < 0.4f || 2.5f < f) {
            f = 1.0f;
        }
        int i = (f > 1.0f ? 1 : (f == 1.0f ? 0 : -1));
        PixivImageUrls pixivImageUrls = pixivIllust.imageUrls;
        return i == 0 ? pixivImageUrls.getSquareMedium() : pixivImageUrls.getMedium();
    }

    /* renamed from: d */
    public void m4487d(PixivIllust pixivIllust, int i) {
        String c = m4488c(pixivIllust);
        this.f19558c.f21621t.setIllust(pixivIllust);
        this.f19560e = c;
        this.f19561f = i;
        m4486e();
        if (i == 1) {
            this.f19558c.f21623v.setBackgroundResource(R.drawable.bg_left_round_white);
            this.f19558c.f21621t.m4463e();
        } else if (i == 2) {
            this.f19558c.f21621t.m4462f();
            this.f19558c.f21623v.setBackgroundResource(R.drawable.bg_right_round_white);
        }
        setInfo(pixivIllust);
    }

    /* renamed from: e */
    public final void m4486e() {
        String str;
        if (getParent() != null && (str = this.f19560e) != null) {
            if (this.f19561f != 0) {
                ThumbnailView thumbnailView = this.f19558c.f21621t;
                thumbnailView.f19698c.m54l(thumbnailView.getContext(), str, thumbnailView.getWidth(), this.f19558c.f21621t.getHeight(), thumbnailView.f19697b.f22163t, this.f19561f);
            } else {
                ThumbnailView thumbnailView2 = this.f19558c.f21621t;
                int width = thumbnailView2.getWidth();
                int height = this.f19558c.f21621t.getHeight();
                PixivImageLoader aVar = thumbnailView2.f19698c;
                Context context = thumbnailView2.getContext();
                ImageView imageView = thumbnailView2.f19697b.f22163t;
                Objects.requireNonNull(aVar);
                MutabilityOwnership.m3745m(context, "context");
                MutabilityOwnership.m3745m(imageView, "imageView");
                if (str.length() == 0) {
                    imageView.setImageResource(R.drawable.shape_bg_illust);
                } else if (aVar.m64b(context)) {
                    Glide.m9615e(context).mo1132o(new GlideUrl(str, aVar.f31482a)).mo1139S(DrawableTransitionOptions.m2637b()).mo470a(new RequestOptions().m445z(new CropTransformation(width, height, 2), true).mo453r(R.drawable.shape_bg_illust)).m9609L(imageView);
                }
            }
            this.f19560e = null;
            this.f19561f = 0;
        }
    }

    @Override // android.widget.FrameLayout, android.view.View, android.view.ViewGroup
    public void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        m4486e();
    }

    public void setAnalyticsParameter(AnalyticsParameter cVar) {
        this.f19558c.f21621t.setAnalyticsParameter(cVar);
    }

    public void setIgnoreMuted(boolean z) {
        this.f19559d = z;
    }

    public void setInfo(PixivIllust pixivIllust) {
        this.f19558c.f21622u.setText(pixivIllust.title);
        this.f19558c.f21620s.setText(this.f19557b.m2579b(pixivIllust.tags));
        this.f19558c.f21619r.setText(String.valueOf(pixivIllust.totalBookmarks));
    }

    public void setLikeButtonEnabled(boolean z) {
        this.f19558c.f21621t.setLikeButtonEnabled(z);
    }

    public void setManga(PixivIllust pixivIllust) {
        if (C3017s.m6470f(pixivIllust, this.f19559d)) {
            setMuteCoverVisibility(0);
            this.f19558c.f21618q.setVisibility(4);
            return;
        }
        setMuteCoverVisibility(8);
        this.f19558c.f21618q.setVisibility(0);
        String c = m4488c(pixivIllust);
        this.f19558c.f21621t.setIllust(pixivIllust);
        this.f19560e = c;
        this.f19561f = 0;
        m4486e();
        setInfo(pixivIllust);
    }

    public void setScreenName(AnalyticsScreenName cVar) {
        this.f19558c.f21621t.setAnalyticsParameter(new AnalyticsParameter(cVar, null, 0));
    }

    public MangaListItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }
}
